<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    @import "link.html"
</head>

<body>
<div class="pt-15">
    <div style="margin-bottom: 10px">
        <a id="refresh" href="javascript:" class="easyui-linkbutton" data-options="iconCls:'fa fa-refresh'">重置</a>
    </div>
    <div id="tree"></div>
</div>
<div id="choose-node-obj"></div>
<script>
  var tree_data2 = [{
    "id": 1,
    "text": "001长河镇",
    "children": [{
      "id": 11,
      "text": "党政办"
    }, {
      "id": 12,
      "text": "社会事务办"
    }, {
      "id": 13,
      "text": "经发办"
    }, {
      "id": 14,
      "text": "综治办"
    }, {
      "id": 15,
      "text": "城建办"
    }]
  }, {
    "id": 2,
    "text": "002横河镇",
    "children": [{
      "id": 21,
      "text": "党政办"
    }]
  }];


  $('#tree').tree({
    data: tree_data2,
    parentField: 'parentId',
    animate: true,
    onClick:function (node) {
      if(!node.children){
        // $('#tree').tree('select',node.target);
        $('#choose-node-obj').attr({
          text:node.text
        });
      }else {
        errorMsg('该选择无效',600);
        $('#choose-node-obj').attr({
          text:''
        });
      }

    }
  });
  $('#refresh').on('click',function () {
    $('#tree').tree('loadData',tree_data2);
  });

</script>
</body>
</html>